#pragma once

#include<iostream>
#include<ctime>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>

#define TaskNum 3

typedef void (*task_t)();//task_t函数指针类型

void Printf()
{
    std::cout<<"printf"<<std::endl;
}
void DownLoad()
{
    std::cout<<"download"<<std::endl;
}
void Flush()
{
    std::cout<<"flush"<<std::endl;
}

task_t tasks[TaskNum];
void LoadTask()
{
    srand(time(nullptr) ^ getpid());
    tasks[0]=Printf;
    tasks[1]=DownLoad;
    tasks[2]=Flush;
}

void Excutetask(int num)
{
    if(num<0||num>2)return;
    tasks[num]();
}

int SelectTask()
{
    return rand()%TaskNum;
}